package com.registry.client.springevent;

import com.registry.client.service.RegistryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

/**
 * ApplicationRunner Spring启动成功后做一些初始化操作，这里也可以用 implements ApplicationListener<ApplicationStartedEvent>代替
 */
public class SpringStartEvent implements ApplicationRunner {

    @Autowired
    private RegistryService registryService;
    /**
     * 服务注册到注册中心
     * @param args
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 注册
        registryService.registry();

    }
}
